package org.blogsomy.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.codec.digest.DigestUtils;
import org.blogsomy.model.entities.User;

import com.google.code.lightsomy.annotations.Action;
import com.google.code.lightsomy.annotations.Controller;

@Controller
public class Install extends BaseController {

	@Action
	public void index(HttpServletRequest req, HttpServletResponse res) throws Exception {
		if (getDaoFacade().getUserDao().find("test") == null) {
			User user = new User();
			user.setName("test");
			user.setPassword(DigestUtils.shaHex("test"));
			user.setRealname("Test");
			user.setSurname("Testowski");
			getDaoFacade().addUser(user);
		}
	}
	
}
